package org.one.stone.soup.grfxML;

import org.one.stone.soup.entity.KeyValuePair;

  /*
 * Copyright 2000-2001 Wet-Wired.com Ltd.,
 * Portsmouth England
 * All rights reserved.
 */

/**
	*
	* @author Nik Cross
*/
public class TagModifier {
	public int flavour;
	public String DEFAULT_ID;
	private KeyValuePair[] attributes;

/*----------------- State Modifiers ------------------------------*/

	public static final int STATE_TYPE_STATE_CODE = 0;

	public static final TagModifier STATE_TYPE_STATE =
		new TagModifier(
			STATE_TYPE_STATE_CODE,
			"_State", new KeyValuePair[]{
						new KeyValuePair(Token.STATE,Token.STATE)
			}
		);

/*----------------- Size Modifiers ------------------------------*/

	public static final int SIZE_TYPE_SIZE_CODE = 0;
	public static final int SIZE_TYPE_COUNT_CODE = 1;
	public static final int SIZE_TYPE_ANGLE_CODE = 2;
	public static final int SIZE_TYPE_THICKNESS_CODE = 3;

	public static final TagModifier SIZE_TYPE_SIZE =
		new TagModifier(
			SIZE_TYPE_SIZE_CODE,
			"_Size", new KeyValuePair[]{
						new KeyValuePair(Token.VALUE,Token.SIZE)
			}
		);

	public static final TagModifier SIZE_TYPE_COUNT =
		new TagModifier(
			SIZE_TYPE_COUNT_CODE,
			"_Count", new KeyValuePair[]{
						new KeyValuePair(Token.VALUE,Token.COUNT)
			}
		);

	public static final TagModifier SIZE_TYPE_THICKNESS =
		new TagModifier(
			SIZE_TYPE_THICKNESS_CODE,
			"_Thickness", new KeyValuePair[]{
						new KeyValuePair(Token.VALUE,Token.WIDTH)
			}
		);

	public static final TagModifier SIZE_TYPE_ANGLE =
		new TagModifier(
			SIZE_TYPE_ANGLE_CODE,
			"_Angle", new KeyValuePair[]{
						new KeyValuePair(Token.VALUE,Token.DEGREES),
						new KeyValuePair(Token.MIN_VALUE,Token.MIN_DEGREES),
						new KeyValuePair(Token.MAX_VALUE,Token.MAX_DEGREES)
			}
		);

/*----------------- Scale Modifiers ------------------------------*/
	public static final int SCALE_TYPE_SCALE_CODE = 0;

	public static final TagModifier SCALE_TYPE_SCALE =
		new TagModifier(
			SCALE_TYPE_SCALE_CODE,
			"_Scale", new KeyValuePair[] {
					new KeyValuePair(Token.VALUE, Token.FACTOR)
			}
		);

/*----------------- Point Modifiers ------------------------------*/

	public static final int POINT_TYPE_POINT_CODE = 0;
	public static final int POINT_TYPE_SIZE_CODE = 1;
	public static final int POINT_TYPE_BOUNDS_CODE = 2;
	public static final int POINT_TYPE_VECTOR_CODE = 3;

	public static final TagModifier POINT_TYPE_POINT =
		new TagModifier(
			POINT_TYPE_POINT_CODE,
			"_Point", new KeyValuePair[]{
						new KeyValuePair(Token.X,Token.X),
						new KeyValuePair(Token.X_MIN,Token.X_MIN),
						new KeyValuePair(Token.X_MAX,Token.X_MAX),
						new KeyValuePair(Token.Y,Token.Y),
						new KeyValuePair(Token.Y_MIN,Token.Y_MIN),
						new KeyValuePair(Token.Y_MAX,Token.Y_MAX)
			}
		);

	public static final TagModifier POINT_TYPE_BOUNDS =
		new TagModifier(
			POINT_TYPE_BOUNDS_CODE,
			"_Bounds", new KeyValuePair[]{
						new KeyValuePair(Token.X,"width"),
						new KeyValuePair(Token.X_MIN,"startX"),
						new KeyValuePair(Token.X_MAX,"endX"),
						new KeyValuePair(Token.Y,"height"),
						new KeyValuePair(Token.Y_MIN,"startY"),
						new KeyValuePair(Token.Y_MAX,"endY")
			}
		);

	public static final TagModifier POINT_TYPE_VECTOR =
		new TagModifier(
			POINT_TYPE_VECTOR_CODE,
			"_Vector", new KeyValuePair[]{
						new KeyValuePair(Token.X,Token.X),
						new KeyValuePair(Token.X_MIN,Token.X_MIN),
						new KeyValuePair(Token.X_MAX,Token.X_MAX),
						new KeyValuePair(Token.Y,Token.Y),
						new KeyValuePair(Token.Y_MIN,Token.Y_MIN),
						new KeyValuePair(Token.Y_MAX,Token.Y_MAX)
			}
		);

/*----------------- Point3D Modifiers ------------------------------*/

	public static final int POINT3D_TYPE_COLOR_CODE = 0;

	public static final TagModifier POINT3D_TYPE_COLOR =
		new TagModifier(
			POINT3D_TYPE_COLOR_CODE,
			"_Color",new KeyValuePair[]{
						new KeyValuePair(Token.X,Token.RED),
						new KeyValuePair(Token.Y,Token.GREEN),
						new KeyValuePair(Token.Z,Token.BLUE),
						new KeyValuePair(Token.T,Token.ALPHA)
			}
		);

/*----------------- String Modifiers ------------------------------*/

	public static final int STRING_TYPE_STRING_CODE = 0;
	public static final int STRING_TYPE_FILE_CODE = 1;

	public static final TagModifier STRING_TYPE_STRING =
		new TagModifier(
			STRING_TYPE_STRING_CODE,
			"_String", new KeyValuePair[]{
						new KeyValuePair(Token.VALUE,Token.VALUE)
			}
		);

	public static final TagModifier STRING_TYPE_FILE =
		new TagModifier(
			STRING_TYPE_FILE_CODE,
			"_File", new KeyValuePair[]{
						new KeyValuePair(Token.VALUE,Token.URL)
			}
		);
private TagModifier(int flav,String id,KeyValuePair[] attribs) {
	super();
	flavour = flav;
	DEFAULT_ID = id;
	attributes = attribs;
}
public String getAttributeAlias(int index) {
	if(index>attributes.length)
	{
		return null;
	}
	else
	{
		return attributes[index].value;
	}
}
public String getAttributeAlias(String name) {

	for(int loop=0;loop<attributes.length;loop++)
	{
		if( attributes[loop].key.equals(name) )
		{
			return attributes[loop].value;
		}
	}
	return name;
}
public int getAttributeCount() {
	return attributes.length;
}
public String getAttributeName(int index) {
	if(index>attributes.length)
	{
		return null;
	}
	else
	{
		return attributes[index].key;
	}
}
public String getAttributeName(String alias) {

	for(int loop=0;loop<attributes.length;loop++)
	{
		if( attributes[loop].value.equals(alias) )
		{
			return attributes[loop].key;
		}
	}
	return alias;
}
}
